<%@page import="lib_model.Product.Products"%>
<%@page import="lib_model.Factories.Factory"%>
<%@page import="java.util.ArrayList"%>
<%@page import="lib_model.Factories.Stocks_factory"%>
<%@page import="lib_model.Factories.Stock_factory_history"%>
<%@page import="lib_model.Account.Account_factory"%>
<%@page import="lib_model.Account.Account"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="../templates/Factories.jsp"></jsp:include>
Stock History Details
<jsp:include page="../templates/Title.jsp"></jsp:include>
<jsp:include page="../templates/StyleFac.jsp"></jsp:include>
<div class="body-center w960">
<h2 class="title-show">Stock History</h2>
<table class="tb">
	<thead>
		<tr>
			<th align="left" width="20%">Date</th>
			<th align="left" width="20%">Product</th>
			<th align="left" width="20%">Username</th>
			<th align="left" width="20%">Factory</th>
			<th align="left" width="20%">Description</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<th align="left" width="20%"></th>
			<th align="left" width="20%"></th>
			<th align="left" width="20%"></th>
			<th align="left" width="20%"></th>
			<th align="left" width="20%"></th>
		</tr>
	</tfoot>
	<tbody>
		<%
			Account acc = (Account) request.getSession().getAttribute("User");
			String usn = acc.username;
			int fac_id = 0;
			fac_id = ((Account_factory) (new Account_factory(usn)
					.GetInformation().ObjResult)).factory_id_ref;
			if (fac_id == 0) {
				request.getSession().removeAttribute("User");
				response.sendRedirect("../pages/home.jsp");
			} else {
				Stock_factory_history sh = new Stock_factory_history();
				ArrayList<Stock_factory_history> arr = (ArrayList<Stock_factory_history>) sh
						.Select().ObjResult;
				for (Stock_factory_history shh : arr) {
					if (shh.factory_id_ref == Integer.parseInt(request
							.getParameter("idfactory"))
							&& shh.products_id_ref == Integer.parseInt(request
									.getParameter("idproduct"))) {
		%>
		<tr>
			<td><%=shh.date_create%></td>
			<td><%=((Products) ((new Products(
								shh.products_id_ref)).GetInformation().ObjResult)).name%> <a target="_black"
				href="../pages/product-detail.jsp?id=<%=sh.products_id_ref%>">View</a></td>
			<td><%=shh.username_ref%></td>
			<td><b><%=((Factory) ((new Factory(shh.factory_id_ref))
								.GetInformation().ObjResult)).name%></b></td>
			<td><%=shh.description%></td>
		</tr>

		<%
			}
				}
			}
		%>
	</tbody>
</table>
</div>
<jsp:include page="../templates/Footer.jsp"></jsp:include>